package com.atguigu.crowd.handle;

import com.atguigu.crowd.api.MySQLReomteService;
import com.atguigu.crowd.constant.CrowdConstan;
import com.atguigu.crowd.entity.vo.PortalTypeVO;
import com.atguigu.crowd.util.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author zzqstart
 * @Description
 * @date 2022-09-16 20:39
 */
@Controller
public class PortalHandler {
    @Autowired
    private MySQLReomteService mySQLReomteService;
    @RequestMapping("/")
    public String showPortalPage(Model model){

        ResultEntity<List<PortalTypeVO>> portalTypeProjectDataRemote = mySQLReomteService.getPortalTypeProjectDataRemote();
        String result = portalTypeProjectDataRemote.getResult();
        if (ResultEntity.FALIED.equals(result)){
            return "portal";
        }
        List<PortalTypeVO> portalTypeVOList = portalTypeProjectDataRemote.getData();
        model.addAttribute(CrowdConstan.ATTR_NAME_PORTAL_DATA,portalTypeVOList);
        return "portal";
    }
}
